﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/MasterPages/Site.Master" Inherits="RushTracker.Web.UI.RushTrackerViewPage<IList<Category>>" %>

<asp:Content runat="server" ContentPlaceHolderID="head">
    <link rel="stylesheet" type="text/css" href="<%= Page.ResolveClientUrl("~/css/jquery.treeview.css") %>" />
    <script type="text/javascript" language="javascript" src="<%= Page.ResolveClientUrl("~/js/jquery.treeview.min.js") %>"></script>
    
    <script type="text/javascript">
        $(document).ready(function () {
            $("#createcategorylink").click(function () {
                $.get($(this).attr("href"), function (data) {
                    var f = $(data);
                    var t = f.find("#title-createcategory");

                    $(data).dialog({ width: 400, height: 392, modal: true, title: t.html(), resizable: false });
                });

                return false;
            });

            $("#addmetafield").live('click', function () {
                var t = $("#existingmetafields :selected");
                var f = $("#categorymetafields");

                $("#metafieldlist").append($("<li></li>").html(t.html()));
                f.val(f.val() + "," + t.val());

                return false;
            });

            $("#categorytree").treeview();

            $(".categorytreelink").click(function () {
                $("#categorydetails").html("");
                $("#detailsloader").show();

                $.get($(this).attr("href"), function (data) {
                    $("#categorydetails").html(data);
                    $("#detailsloader").hide();
                });

                return false;
            });
        });
    </script>
</asp:Content>

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="mainContent">
    <div class="box">
        <h2>Categories</h2>
        
        <div class="boxcontent">
            <table class="fullwidth">
                <tr>
                    <td class="highlight">Categories</td>
                    <td class="highlight">Details <span id="detailsheader"></span></td>
                </tr>
                
                <tr>
                    <td valign="top" style="width: 25%;">
                        <ul id="categorytree" class="filetree">
                        <%
                        foreach (Category c in Model)
                        {
                        Html.RenderPartial("~/Views/Admin/Controls/CategoryItem.ascx", c);
                        }
                        %>
                        </ul>
                    </td>
                    
                    <td valign="top">
                        <img src="<%= Page.ResolveClientUrl("~/img/loader.gif") %>" alt="loader" class="ajaxloader" id="detailsloader" />
                        <div id="categorydetails"></div>
                    </td>
                </tr>
            </table>
        </div>
        
        <div class="boxfooter">
            <%= Html.ActionLink("Create category", "CreateCategory", "Admin", null, new { id = "createcategorylink" }) %>
        </div>
    </div>
</asp:Content>